package cn.iocoder.yudao.module.peizhen.dal.mysql.paitent;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.peizhen.controller.admin.paitent.vo.PaitentPageReqVO;
import cn.iocoder.yudao.module.peizhen.dal.dataobject.paitent.PaitentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.peizhen.controller.app.paitent.vo.*;

/**
 * 用户的陪诊病人 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface PaitentMapper extends BaseMapperX<PaitentDO> {

    default PageResult<PaitentDO> selectPage(AppPaitentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PaitentDO>()
                .eqIfPresent(PaitentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(PaitentDO::getIsAdult, reqVO.getIsAdult())
                .likeIfPresent(PaitentDO::getName, reqVO.getName())
                .eqIfPresent(PaitentDO::getSex, reqVO.getSex())
                .eqIfPresent(PaitentDO::getPhone, reqVO.getPhone())
                .eqIfPresent(PaitentDO::getCardNum, reqVO.getCardNum())
                .eqIfPresent(PaitentDO::getRelation, reqVO.getRelation())
                .eqIfPresent(PaitentDO::getIsWalk, reqVO.getIsWalk())
                .betweenIfPresent(PaitentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PaitentDO::getId));
    }

    default PageResult<PaitentDO> selectPage(PaitentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PaitentDO>()
                .eqIfPresent(PaitentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(PaitentDO::getIsAdult, reqVO.getIsAdult())
                .likeIfPresent(PaitentDO::getName, reqVO.getName())
                .eqIfPresent(PaitentDO::getSex, reqVO.getSex())
                .eqIfPresent(PaitentDO::getPhone, reqVO.getPhone())
                .eqIfPresent(PaitentDO::getCardNum, reqVO.getCardNum())
                .eqIfPresent(PaitentDO::getRelation, reqVO.getRelation())
                .eqIfPresent(PaitentDO::getIsWalk, reqVO.getIsWalk())
                .betweenIfPresent(PaitentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PaitentDO::getId));
    }

}